<!--
 * @Author: your name
 * @Date: 2021-09-08 18:34:48
 * @LastEditTime: 2021-09-09 09:29:11
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \ej-webui\src\pages\personal.vue
-->
<template>
  <div class="production">
    <div class="btns">
      <!-- 检索框 -->
      <el-form :inline="true" :model="params" size="small" style="vertical-align:center">
         <el-date-picker v-model="value1" type="datetimerange" size="small"
         start-placeholder="开始日期"
         end-placeholder="结束日期"
         :default-time="['12:00:00']">
       </el-date-picker>

        <el-form-item>
          <el-select style="margin-left:10px" clearable v-model="params.applyType" placeholder="请选择类型">
            <el-option label="充值" value="充值"></el-option>
            <el-option label="提现" value="提现"></el-option>
          </el-select>
        </el-form-item>

       
        <el-form-item>
          <el-select clearable v-model="params.status" placeholder="请选择状态">
            <el-option label="通过" value="通过"></el-option>
            <el-option label="不通过" value="不通过"></el-option>
            <el-option label="未审核" value="未审核"></el-option>
          </el-select>
        </el-form-item>
       
        <el-button
          type="primary"
          size="small"
          style="margin-right: 10px;"
          @click="pageQueryProductions"
          icon="el-icon-search"
          >查询</el-button
        >
      </el-form>
    </div>
    <div class="content">
      <!-- 表格 -->
      <el-table :data="resData.list" style="width: 100%" size="small">
        <el-table-column type="index" label="序号"></el-table-column>
        <el-table-column label="申请人编号" prop="userId"></el-table-column>
        <el-table-column label="申请时间" prop="applyTime"></el-table-column>
        <el-table-column label="变更类型" prop="applyType"></el-table-column>
        <el-table-column label="变更资金" prop="money"></el-table-column>

        <el-table-column label="状态" prop="status">
          <template v-slot="scope">
            <el-tag
              v-if="scope.row.status == '通过'"
              size="mini"
              type="success"
              >{{ scope.row.status }}</el-tag
            >
            <el-tag v-else size="mini" type="danger">{{
              scope.row.status
            }}
            </el-tag>
          </template>
        </el-table-column>
       
        <el-table-column label="操作">
            <template v-slot="scope">
              <el-button type="text" style="color:blue"  @click="offlineHandler(scope.row.id, $event)">通过</el-button>
               <el-button type="text" style="color:red"  @click="offlineHandler(scope.row.id, $event)">不通过</el-button>
            </template>
        </el-table-column>
      </el-table>

      <!-- 分页 -->
      <el-pagination
        style="float:right;margin-top:5px"
        background
        layout="prev, pager, next, sizes"
        :total="resData.total"
        :page-size="params.pageSize"
        :current-page="params.page"
        @current-change="pageChangeHandler"
        :page-sizes="[5, 10, 15]"
        @size-change="pageSizeChangeHandler"
      >
      </el-pagination>
   

    </div>
  </div>
</template>
<script>
import requset from "@/utils/request";
import _ from "lodash";
export default {
  data() {
    return {
      params: {
        page: 1,
        pageSize: 5,
      },
      value1: '',
      resData: {},
      categories: [],
      title: "",
      production: {},
    };
  },
  methods: {
    // 导入状态机中的方法
    // ...mapActions("category", ["findAllCategories"]),
    // 分页查询产品表格
    async pageQueryProductions() {
      // 过滤数据将空字符串删除
      for (let key in this.params) {
        if (this.params[key] == "") {
          delete this.params[key];
        }
      }
      let res = await requset.get("/accountApply/pageQueryAccountApply", {
        params: this.params,
      });
      this.resData = res.data;
    },
    // page改变事件
    pageChangeHandler(page) {
      this.params.page = page;
      this.pageQueryProductions();
    },
    // pageSize改变事件
    pageSizeChangeHandler(pageSize) {
      this.params.pageSize = pageSize;
      this.pageQueryProductions();
    },

    offlineHandler(id, e) {
      this.$confirm("是否确认该操作?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        if (e.target.innerText == "不通过") {
          requset.get("/accountApply/checkNoPass", { params: { id } }).then((res) => {
            this.pageQueryProductions(); // 重载数据
            this.$message.success(res.message); // 提示信息
          });
        } else {
          requset.get("/accountApply/checkPass", { params: { id } }).then((res) => {
            this.pageQueryProductions(); // 重载数据
            this.$message.success(res.message); // 提示信息
          });
        }
      });
    },

  },
  created() {
    this.pageQueryProductions(); // 分页查询产品
    this.findAllCategories().then((res) => {
      this.categories = res.data.list;
    }); // 查询所有产品栏目
  },
};
</script>
<style>
</style>